# Disponivel no pacote de programas como: primes3.py
def primes(N):
  N = int(N) + bool(N % 1)  # Round up floating-point N
  primos = [x for x in (2, 3, 5, 7, 11, 13) if x < N]
  if N > 17:
    candidates = [x for x in xrange((N - 2) | 1, 15, -2)
                  if x % 3 and x % 5 and x % 7 and x % 11 and x % 13]
    top = int(N ** 0.5)
    while (top+1) * (top+1) <= N:
      top += 1
    while 1:
      p = candidates.pop()
      primos.append(p)
      if p > top:
        break
      candidates = filter(p.__rmod__, candidates)
    candidates.reverse()
    primos.extend(candidates)
  return primos
  
